package com.cn.goodsadmin;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.http.MediaType;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
@Slf4j
@RestController
@ServletComponentScan
@EnableCaching
@EnableTransactionManagement
@EntityScan(basePackages = {"com.cn.goodsadmin.po"})
@EnableAspectJAutoProxy(exposeProxy=true)
public class GoodsAdminApplication {

    public static void main(String[] args) {
        SpringApplication.run(GoodsAdminApplication.class, args);
    }

    /**
     * 如果是string 并且不是json 优先用string 输出
     *
     * @return string的转换器
     */
    @Bean
    public StringHttpMessageConverter stringHttpMessageConverters() {
        StringHttpMessageConverter stringCover = new StringHttpMessageConverter();
        List<MediaType> stringMedisTypes = new ArrayList<>();
        stringMedisTypes.add(MediaType.APPLICATION_OCTET_STREAM);//设定Json格式
        stringCover.setSupportedMediaTypes(stringMedisTypes);
        return new StringHttpMessageConverter();
    }

}
